﻿using DevExpress.LookAndFeel;
using DevExpress.Utils.MVVM;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace Decoder3
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1()
        {
            InitializeComponent();
            new Thread(() =>

            {
                while (true)

                {
                    try
                    {
                        String str = "当前时间：" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
                        str = str + "。本软件由越野车装配厂技术科开发，联系方式：86958239。";
                        toolStripStatusLabel1.Text = str;
                    }
                    catch { }

                    Thread.Sleep(1000);
                }
            })
            { IsBackground = true }.Start();

            toolStripStatusLabel1.Text = "越野车装配厂技术科开发";
        }
        private struct Baowen
        {
            public int nums;
            public string content;
            public string types;
        }
        private void toolStripStatusLabel4_Click(object sender, EventArgs e)
        {

        }

        private void toolStripStatusLabel3_Click(object sender, EventArgs e)
        {
            var Helps = new Help();
            Helps.ShowDialog();
        }
        public static string Fanzhuan(string str)
        {
            string fanzhuan = "";
            int n = str.Length;
            int n2 = n / 2;
            for (int i = 1; i <= n2; i++)
            {
                fanzhuan = fanzhuan + str.Substring(n - 2 * i, 2);
            }
            return fanzhuan;
        }

        public static string PrefixInteger(string str, int n)
        {
            string s = str.ToString().PadLeft(n, '0');
            return s;
        }
        public static string ZhuanHuan2(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g12"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g12"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g12"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g12"
                }
            };
            //string msg1 = ZhuanHuan1(val1, "g1", 0, 2, false);

            string ztm1 = zhi.Substring(0, 2);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
            //补0
            var zhis = PrefixInteger(ztm1_2, 8);
            //取出第1、2两位
            var zhi6 = zhis.Substring(0, 2);
            //转10进制
            var zhi2 = Convert.ToInt32(zhi6, 2);

            String str = "未找到";
            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g12" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string ZhuanHuan3(string zhi)
        {
            //string msg1 = ZhuanHuan1(val1, "g1", 0, 2, false);

            string ztm1 = zhi.Substring(2, 4);
            //翻转
            ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                      //补0
                                                      //var zhis = PrefixInteger(ztm1_2, 16);
                                                      //取出第1、2两位
                                                      // var zhi6 = zhis.Substring(0, 2);
                                                      //转10进制
            var zhi2 = Convert.ToInt32(ztm1_2, 2);

            String str = "";

            return str + zhi2 * 0.1 + "（V）";
        }

        public static string ZhuanHuan4(string zhi)
        {
            string ztm1 = zhi.Substring(6, 4);
            //翻转
            ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                      //补0
                                                      //var zhis = PrefixInteger(ztm1_2, 16);
                                                      //取出第1、2两位
                                                      // var zhi6 = zhis.Substring(0, 2);
                                                      //转10进制
            var zhi2 = Convert.ToInt32(ztm1_2, 2);
            var zhi3 = zhi2 * 0.1 - 1000;

            String str = "";
            //return zhi2;
            return str + zhi3 + "（A）";
        }

        public static string ZhuanHuan5(string zhi)
        {
            string ztm1 = zhi.Substring(10, 4);
            //翻转
            ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                      //补0
                                                      //var zhis = PrefixInteger(ztm1_2, 16);
                                                      //取出第1、2两位
                                                      // var zhi6 = zhis.Substring(0, 2);
                                                      //转10进制
            var zhi2 = Convert.ToInt32(ztm1_2, 2);
            var zhi3 = zhi2 - 32000;

            String str1 = "";

            return str1 + zhi3 + "（rpm）";
        }

        public static string zh21(string zhi)
        {
            string ztm1 = zhi.Substring(14, 2);
            //翻转
            // ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                    //补0
                                                    //var zhis = PrefixInteger(ztm1_2, 16);
                                                    //取出第1、2两位
                                                    // var zhi6 = zhis.Substring(0, 2);
                                                    //转10进制
                                                    //var zhi2 = Convert.ToInt32(ztm1_2, 2);
            var zhi3 = ztm1_10 - 40;

            String str1 = "";

            return str1 + zhi3 + "（℃）";
        }

        public static string zh22(string zhi)
        {
            string ztm1 = zhi.Substring(12, 2);
            //翻转
            // ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                    //补0
                                                    //var zhis = PrefixInteger(ztm1_2, 16);
                                                    //取出第1、2两位
                                                    // var zhi6 = zhis.Substring(0, 2);
                                                    //转10进制
                                                    //var zhi2 = Convert.ToInt32(ztm1_2, 2);
            var zhi3 = ztm1_10 - 40;

            String str1 = "";

            return str1 + zhi3 + "（℃）";
        }

        public static string zh31(string zhi)
        {
            string ztm1 = zhi.Substring(0, 8);
            //翻转
            ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                    //补0
                                                    //var zhis = PrefixInteger(ztm1_2, 16);
                                                    //取出第1、2两位
                                                    // var zhi6 = zhis.Substring(0, 2);
                                                    //转10进制
                                                    //var zhi2 = Convert.ToInt32(ztm1_2, 2);
            var zhi3 = ztm1_10 * 0.05;

            String str1 = "";

            return str1 + zhi3 + "（h）";
        }

        public static string zh41(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=2,
                    content="控制电源接通（低压上电）",
                    types="g21"
                },
                new Baowen(){
                    nums=3,
                    content="控制器自检允许上高压",
                    types="g21"
                },
                new Baowen(){
                    nums=4,
                    content="高压接通中",
                    types="g21"
                },
                new Baowen(){
                    nums=7,
                    content="高压接通准备就绪",
                    types="g21"
                },
                new Baowen(){
                    nums=8,
                    content="工作状态",
                    types="g21"
                },
                new Baowen(){
                    nums=23,
                    content="高压切断中",
                    types="g21"
                },
                new Baowen(){
                    nums=24,
                    content="高压切断完成",
                    types="g21"
                },
                new Baowen(){
                    nums=30,
                    content="故障状态",
                    types="g21"
                },
                new Baowen(){
                    nums=31,
                    content="诊断待定",
                    types="g21"
                }
            };
            string ztm1 = zhi.Substring(0, 2);

            //翻转
            // ztm1 = Fanzhuan(ztm1);

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 6);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g21" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str; ;
        }

        public static string zh42(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g22"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g22"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g22"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g22"
                }
            };
            string ztm1 = zhi.Substring(0, 2);

            //翻转
            // ztm1 = Fanzhuan(ztm1);

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g22" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str; ;
        }

        public static string zh43(string zhi)
        {
            string ztm1 = zhi.Substring(2, 4);

            //翻转
            ztm1 = Fanzhuan(ztm1);

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var ztms = ztm1_10 * 0.1;

            String str = "电压超范围";
            if (ztms < 1000)
            {
                str = ztms + "（V）";
            }
            return str; ;
        }

        public static string zh44(string zhi)
        {
            string ztm1 = zhi.Substring(6, 2);

            //翻转
            //ztm1 = Fanzhuan(ztm1);

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var ztms = ztm1_10;

            String str = "电流超范围";
            if (ztms < 250)
            {
                str = ztms + "（A）";
            }
            return str; ;
        }

        public static string zh45(string zhi)
        {
            string ztm1 = zhi.Substring(8, 4);

            //翻转
            ztm1 = Fanzhuan(ztm1);

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var ztms = ztm1_10;

            String str = "转速超范围";
            if (ztms <= 15000)
            {
                str = ztms + "（rpm）";
            }
            return str; ;
        }

        public static string zh46(string zhi)
        {
            string ztm1 = zhi.Substring(12, 2);

            //翻转
            //ztm1 = Fanzhuan(ztm1);

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var ztms = ztm1_10 - 40;

            String str = "温度超范围";
            if (ztms <= 210)
            {
                str = ztms + "（℃）";
            }
            return str; ;
        }

        public static string zh47(string zhi)
        {
            string ztm1 = zhi.Substring(14, 2);

            //翻转
            //ztm1 = Fanzhuan(ztm1);

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var ztms = ztm1_10 - 40;

            String str = "温度超范围";
            if (ztms <= 210)
            {
                str = ztms + "（℃）";
            }
            return str; ;
        }

        public static string zh221(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=2,
                    content="控制电源接通（低压上电）",
                    types="g221"
                },
                new Baowen(){
                    nums=3,
                    content="控制器自检允许上高压",
                    types="g221"
                },
                new Baowen(){
                    nums=4,
                    content="高压接通中",
                    types="g221"
                },
                new Baowen(){
                    nums=7,
                    content="高压接通准备就绪",
                    types="g221"
                },
                new Baowen(){
                    nums=8,
                    content="工作状态",
                    types="g221"
                },
                new Baowen(){
                    nums=23,
                    content="高压切断中",
                    types="g221"
                },
                new Baowen(){
                    nums=24,
                    content="高压切断完成",
                    types="g221"
                },
                new Baowen(){
                    nums=30,
                    content="故障状态",
                    types="g221"
                },
                new Baowen(){
                    nums=31,
                    content="诊断待定",
                    types="g221"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //  ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 6);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g221" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh222(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g222"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g222"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g222"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g222"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //  ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g222" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh223(string zhi)
        {
            string ztm1 = zhi.Substring(2, 4);

            ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            var zhis = ztm1_10 * 0.1;
            String str = "电压超范围";
            if (zhis <= 1000)
            {
                str = zhis + "（V）";
            }
            return str;
        }

        public static string zh224(string zhi)
        {
            string ztm1 = zhi.Substring(6, 2);

            // ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "电流超范围";
            if (ztm1_10 <= 250)
            {
                str = ztm1_10 + "（A）";
            }
            return str;
        }

        public static string zh225(string zhi)
        {
            string ztm1 = zhi.Substring(8, 4);

            ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "转速超范围";
            if (ztm1_10 <= 15000)
            {
                str = ztm1_10 + "（rpm）";
            }
            return str;
        }

        public static string zh226(string zhi)
        {
            string ztm1 = zhi.Substring(12, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            var zhis = ztm1_10 - 40;
            String str = "温度超范围";
            if (zhis <= 210)
            {
                str = zhis + "（℃）";
            }
            else
            {
                if (zhis == 215)
                {
                    str = "无效值";
                }
            }
            return str;
        }

        public static string zh227(string zhi)
        {
            string ztm1 = zhi.Substring(14, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            var zhis = ztm1_10 - 40;
            String str = "温度超范围";
            if (zhis <= 210)
            {
                str = zhis + "（℃）";
            }
            else
            {
                if (zhis == 215)
                {
                    str = "无效值";
                }
            }
            return str;
        }

        public static string zh231(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=2,
                    content="控制电源接通（低压上电）",
                    types="g231"
                },
                new Baowen(){
                    nums=3,
                    content="控制器自检允许上高压",
                    types="g231"
                },
                new Baowen(){
                    nums=4,
                    content="高压接通中",
                    types="g231"
                },
                new Baowen(){
                    nums=7,
                    content="高压接通准备就绪",
                    types="g231"
                }
                ,
                new Baowen(){
                    nums=8,
                    content="工作状态",
                    types="g231"
                }
                ,
                new Baowen(){
                    nums=23,
                    content="高压切断中",
                    types="g231"
                }
                ,
                new Baowen(){
                    nums=24,
                    content="高压切断完成",
                    types="g231"
                }
                ,
                new Baowen(){
                    nums=30,
                    content="故障状态",
                    types="g231"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //  ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 6);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g231" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh232(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g232"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g232"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g232"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g232"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //  ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g232" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh233(string zhi)
        {
            string ztm1 = zhi.Substring(2, 4);

            ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            var zhis = ztm1_10 * 0.1;
            String str = "电压超范围";
            if (zhis <= 1000)
            {
                str = zhis + "（V）";
            }
            return str;
        }

        public static string zh234(string zhi)
        {
            string ztm1 = zhi.Substring(6, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            var zhis = ztm1_10;
            String str = "电压超范围";
            if (zhis <= 25)
            {
                str = zhis + "（V）";
            }
            return str;
        }

        public static string zh235(string zhi)
        {
            string ztm1 = zhi.Substring(8, 2);

            // ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "电流超范围";
            if (ztm1_10 <= 250)
            {
                str = ztm1_10 + "（A）";
            }
            return str;
        }

        public static string zh236(string zhi)
        {
            string ztm1 = zhi.Substring(10, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //  var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            // var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            //var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            var zhis = ztm1_10 - 40;
            String str = "温度超范围";
            if (zhis <= 210)
            {
                str = zhis + "（℃）";
            }
            else
            {
                if (zhis == 215)
                {
                    str = "无效值";
                }
            }
            return str;
        }

        public static string zh241(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=0,
                    content="",
                    types="g241"
                },
                new Baowen(){
                    nums=3,
                    content="低压上电完成",
                    types="g241"
                },
                new Baowen(){
                    nums=4,
                    content="高压接通中",
                    types="g241"
                },
                new Baowen(){
                    nums=8,
                    content="工作状态",
                    types="g241"
                }                ,
                new Baowen(){
                    nums=24,
                    content="高压切断完成",
                    types="g241"
                }
                ,
                new Baowen(){
                    nums=30,
                    content="故障状态",
                    types="g241"
                },
                new Baowen(){
                    nums=31,
                    content="诊断标定",
                    types="g241"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //  ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 6);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g241" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh242(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g242"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g242"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g242"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g242"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //  ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g242" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh243(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="绝缘阻值小于500k",
                    types="g242"
                },
                new Baowen(){
                    nums=1,
                    content="绝缘阻值小于315k",
                    types="g242"
                },
                new Baowen(){
                    nums=2,
                    content="接线故障",
                    types="g242"
                },
                new Baowen(){
                    nums=3,
                    content="设备故障",
                    types="g242"
                },
                new Baowen(){
                    nums=255,
                    content="绝缘监测仪不工作",
                    types="g242"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            //var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhis, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g242" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh244(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="绝缘阻值小于500k",
                    types="g242"
                },
                new Baowen(){
                    nums=1,
                    content="绝缘阻值小于315k",
                    types="g242"
                },
                new Baowen(){
                    nums=2,
                    content="接线故障",
                    types="g242"
                },
                new Baowen(){
                    nums=3,
                    content="设备故障",
                    types="g242"
                },
                new Baowen(){
                    nums=255,
                    content="绝缘监测仪不工作",
                    types="g242"
                }
            };

            string ztm1 = zhi.Substring(4, 4);

            ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            //  var zhis = PrefixInteger(ztm1_2, 16);//补0
            //var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(ztm1_2, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g242" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh245(string zhi)
        {
            string ztm1 = zhi.Substring(8, 4);

            ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 16);//补0
            //var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhis, 2);//转10进制

            String str = "异常";
            if (zhi2 <= 1000)
            {
                str = zhi2 + "（V）";
            }
            else
            {
                if (zhi2 == 65535)
                {
                    str = "无效";
                }
            }
            return str;
        }

        public static string zh246(string zhi)
        {
            string ztm1 = zhi.Substring(14, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    // var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            //var zhis = PrefixInteger(ztm1_2, 16);//补0
            //var zhi6 = zhis.Substring(0, 2);

            // var zhi2 = Convert.ToInt32(zhis, 2);//转10进制

            String str = "不在范围内";
            if (ztm1_10 <= 255)
            {
                str = ztm1_10 + "";
            }

            return str;
        }

        public static string zh251(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(4, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh252(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(6, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh253(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh254(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh255(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(6, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh256(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(4, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh257(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh258(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g251"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g251"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g251"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g251"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g251" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh259(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=2,
                    content="控制电源接通（低压上电）",
                    types="g259"
                },
                new Baowen(){
                    nums=3,
                    content="控制器自检允许上高压",
                    types="g259"
                },
                new Baowen(){
                    nums=4,
                    content="高压接通中",
                    types="g259"
                },
                new Baowen(){
                    nums=5,
                    content="预充失败",
                    types="g259"
                },
                new Baowen(){
                    nums=7,
                    content="高压接通准备就绪",
                    types="g259"
                },
                new Baowen(){
                    nums=8,
                    content="工作状态",
                    types="g259"
                },
                new Baowen(){
                    nums=23,
                    content="高压切断中",
                    types="g259"
                }
                ,
                new Baowen(){
                    nums=24,
                    content="高压切断完成",
                    types="g259"
                }
                ,
                new Baowen(){
                    nums=30,
                    content="故障状态",
                    types="g259"
                },
                new Baowen(){
                    nums=31,
                    content="诊断标定",
                    types="g259"
                }
            };

            string ztm1 = zhi.Substring(4, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 6);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g259" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh2510(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g2510"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g2510"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g2510"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g2510"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g2510" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh312(string zhi)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g312"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g312"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g312"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g312"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g312" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh313(string zhi)
        {
            //string msg1 = ZhuanHuan1(val1, "g1", 0, 2, false);

            string ztm1 = zhi.Substring(6, 4);
            //翻转
            ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                    //补0
                                                    //var zhis = PrefixInteger(ztm1_2, 16);
                                                    //取出第1、2两位
                                                    // var zhi6 = zhis.Substring(0, 2);
                                                    //转10进制
                                                    //var zhi2 = Convert.ToInt32(ztm1_2, 2);

            String str = "超范围";
            if (ztm1_10 <= 1000)
            {
                str = ztm1_10 * 0.1 + "（V）";
            }
            return str;
        }

        public static string zh314(string zhi)
        {
            //string msg1 = ZhuanHuan1(val1, "g1", 0, 2, false);

            string ztm1 = zhi.Substring(10, 4);
            //翻转
            ztm1 = Fanzhuan(ztm1);

            //转2进制
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
                                                    //var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2
                                                    //补0
                                                    //var zhis = PrefixInteger(ztm1_2, 16);
                                                    //取出第1、2两位
                                                    // var zhi6 = zhis.Substring(0, 2);
                                                    //转10进制
                                                    //var zhi2 = Convert.ToInt32(ztm1_2, 2);

            String str = "超范围";
            if (ztm1_10 <= 1000)
            {
                str = ztm1_10 * 0.1 - 1000 + "（V）";
            }
            return str;
        }

        public static string zh315(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g315"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g315"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g315"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g315"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(6, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g315" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh316(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g315"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g315"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g315"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g315"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(4, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g315" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh317(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g315"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g315"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g315"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g315"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g315" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh318(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g315"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g315"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g315"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g315"
                }
            };

            string ztm1 = zhi.Substring(2, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(0, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g315" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh319(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="断开",
                    types="g315"
                },
                new Baowen(){
                    nums=1,
                    content="闭合",
                    types="g315"
                },
                new Baowen(){
                    nums=2,
                    content="粘连",
                    types="g315"
                },
                new Baowen(){
                    nums=3,
                    content="无效",
                    types="g315"
                }
            };

            string ztm1 = zhi.Substring(4, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(6, 2);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g315" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh3110(string zhi)
        {
            var baowens = new List<Baowen> {
               new Baowen(){
                    nums=0,
                    content="无充电机充电",
                    types="g315"
                },
                new Baowen(){
                    nums=1,
                    content="充电机充电线连接",
                    types="g315"
                },
                new Baowen(){
                    nums=2,
                    content="准备充电",
                    types="g315"
                },
                new Baowen(){
                    nums=3,
                    content="充电机充电中",
                    types="g315"
                }
                ,
                new Baowen(){
                    nums=4,
                    content="充电机充电完成",
                    types="g315"
                },
                new Baowen(){
                    nums=5,
                    content="充电异常",
                    types="g315"
                },
                new Baowen(){
                    nums=7,
                    content="无效",
                    types="g315"
                }
            };

            string ztm1 = zhi.Substring(4, 2);

            //ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(3, 3);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g315" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string zh311(string zhi)
        {
            var baowens = new List<Baowen> {
                 new Baowen(){
                    nums=2,
                    content="控制电源接通（低压上电）",
                    types="g311"
                },
                new Baowen(){
                    nums=3,
                    content="控制器自检允许上高压",
                    types="g311"
                },
                new Baowen(){
                    nums=4,
                    content="高压接通中",
                    types="g311"
                },
                new Baowen(){
                    nums=8,
                    content="平衡状态",
                    types="g311"
                }
                ,
                new Baowen(){
                    nums=9,
                    content="充电状态",
                    types="g311"
                }
                ,
                new Baowen(){
                    nums=10,
                    content="放电状态",
                    types="g311"
                },
                new Baowen(){
                    nums=23,
                    content="高压切断中",
                    types="g311"
                }
                ,
                new Baowen(){
                    nums=24,
                    content="高压切断完成",
                    types="g311"
                }
                ,
                new Baowen(){
                    nums=30,
                    content="故障状态",
                    types="g311"
                },
                new Baowen(){
                    nums=31,
                    content="诊断标定",
                    types="g311"
                }
            };

            string ztm1 = zhi.Substring(0, 2);

            //  ztm1 = Fanzhuan(ztm1);//翻转

            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 6);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g311" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        public static string ZhuanHuan1(string zhi, string type, int start, int len, bool fanzhuan = false)
        {
            var baowens = new List<Baowen> {
                new Baowen(){
                    nums=2,
                    content="控制电源接通（低压上电）",
                    types="g11"
                },
                new Baowen(){
                    nums=3,
                    content="控制器自检允许上高压','高压接通中",
                    types="g11"
                },
                new Baowen(){
                    nums=4,
                    content="控制电源接通（低压上电）",
                    types="g11"
                },
                new Baowen(){
                    nums=7,
                    content="高压接通准备就绪",
                    types="g11"
                },
                new Baowen(){
                    nums=8,
                    content="工作状态",
                    types="g11"
                },
                new Baowen(){
                    nums=9,
                    content="工作状态",
                    types="g11"
                },
                new Baowen(){
                    nums=10,
                    content="工作状态",
                    types="g11"
                },
                new Baowen(){
                    nums=11,
                    content="工作状态",
                    types="g11"
                },
                new Baowen(){
                    nums=12,
                    content="工作状态",
                    types="g11"
                },
                new Baowen(){
                    nums=13,
                    content="工作状态",
                    types="g11"
                },
                new Baowen(){
                    nums=23,
                    content="高压切断中",
                    types="g11"
                },
                new Baowen(){
                    nums=24,
                    content="高压切断完成",
                    types="g11"
                },
                new Baowen(){
                    nums=30,
                    content="故障状态",
                    types="g11"
                }
                //故障等级
                ,
                new Baowen(){
                    nums=0,
                    content="无故障",
                    types="g12"
                },
                new Baowen(){
                    nums=1,
                    content="1级故障",
                    types="g12"
                },
                new Baowen(){
                    nums=2,
                    content="2级故障",
                    types="g12"
                },
                new Baowen(){
                    nums=3,
                    content="3级故障",
                    types="g12"
                }
            };

            string ztm1 = zhi.Substring(start, len);

            if (fanzhuan == true)
            {
                ztm1 = Fanzhuan(ztm1);//翻转
            }
            var ztm1_10 = Convert.ToInt32(ztm1, 16);//16to10
            var ztm1_2 = Convert.ToString(ztm1_10, 2);//10to2

            var zhis = PrefixInteger(ztm1_2, 8);//补0
            var zhi6 = zhis.Substring(2, 6);

            var zhi2 = Convert.ToInt32(zhi6, 2);//转10进制

            String str = "未找到";

            foreach (Baowen bw in baowens)
            {
                if (bw.types == "g11" && bw.nums == zhi2)
                {
                    str = bw.content;
                }
            }
            return str;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string val1 = textEdit1.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = ZhuanHuan1(val1, "g1", 0, 2, false);

                    tbox_workstatus.Text = msg1;

                    string msg2 = ZhuanHuan2(val1);
                    tbox_FailureLevel.Text = msg2;
                    string msg3 = ZhuanHuan3(val1);
                    tbox_g1dy.Text = msg3;
                    string msg4 = ZhuanHuan4(val1);
                    tbox_g1dl.Text = msg4;
                    string msg5 = ZhuanHuan5(val1);
                    tbox_g1zs.Text = msg5;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            string val1 = textEdit2.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh21(val1);
                    tbx_g21.Text = msg1;
                    string msg2 = zh22(val1);
                    tbx_g22.Text = msg2;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btn_t3_Click(object sender, EventArgs e)
        {
            string val1 = textEdit3.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh31(val1);
                    tbx_g31.Text = msg1;//dasdad
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btn_211_Click(object sender, EventArgs e)
        {
            string val1 = textEdit4.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh41(val1);
                    tbx_g41.Text = msg1;
                    string msg2 = zh42(val1);
                    tbx_g42.Text = msg2;
                    string msg3 = zh43(val1);
                    tbx_g43.Text = msg3;
                    string msg4 = zh44(val1);
                    tbx_g44.Text = msg4;
                    string msg5 = zh45(val1);
                    tbx_g45.Text = msg5;
                    string msg6 = zh46(val1);
                    tbx_g46.Text = msg6;
                    string msg7 = zh47(val1);
                    tbx_g47.Text = msg7;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btn_22_Click(object sender, EventArgs e)
        {
            string val1 = textEdit5.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh221(val1);
                    txb221.Text = msg1;
                    string msg2 = zh222(val1);
                    txb222.Text = msg2;
                    string msg3 = zh223(val1);
                    txb223.Text = msg3;
                    string msg4 = zh224(val1);
                    txb224.Text = msg4;
                    string msg5 = zh225(val1);
                    txb225.Text = msg5;
                    string msg6 = zh226(val1);
                    txb226.Text = msg6;
                    string msg7 = zh227(val1);
                    txb227.Text = msg7;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btn25_Click(object sender, EventArgs e)
        {
            string val1 = textEdit8.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh251(val1);
                    tbx251.Text = msg1;
                    string msg2 = zh252(val1);
                    tbx252.Text = msg2;
                    string msg3 = zh253(val1);
                    tbx253.Text = msg3;
                    string msg4 = zh254(val1);
                    tbx254.Text = msg4;
                    string msg5 = zh255(val1);
                    tbx255.Text = msg5;
                    string msg6 = zh256(val1);
                    tbx256.Text = msg6;
                    string msg7 = zh257(val1);
                    tbx257.Text = msg7;
                    string msg8 = zh258(val1);
                    tbx258.Text = msg8;
                    string msg9 = zh259(val1);
                    tbx259.Text = msg9;
                    string msg10 = zh2510(val1);
                    tbx2510.Text = msg10;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btn_223_Click(object sender, EventArgs e)
        {
            string val1 = textEdit6.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh231(val1);
                    tbx231.Text = msg1;
                    string msg2 = zh232(val1);
                    tbx232.Text = msg2;
                    string msg3 = zh233(val1);
                    tbx233.Text = msg3;
                    string msg4 = zh234(val1);
                    tbx234.Text = msg4;
                    string msg5 = zh235(val1);
                    tbx235.Text = msg5;
                    string msg6 = zh236(val1);
                    tbx236.Text = msg6;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btn224_Click(object sender, EventArgs e)
        {
            string val1 = textEdit7.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh241(val1);
                    tbx241.Text = msg1;
                    string msg2 = zh242(val1);
                    tbx242.Text = msg2;
                    string msg3 = zh243(val1);
                    tbx243.Text = msg3;
                    string msg4 = zh244(val1);
                    tbx244.Text = msg4;
                    string msg5 = zh245(val1);
                    tbx245.Text = msg5;
                    string msg6 = zh246(val1);
                    tbx246.Text = msg6;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void btn31_Click(object sender, EventArgs e)
        {
            string val1 = textEdit9.Text;
            val1 = val1.Replace(" ", "");//去除空格
            if (val1 != "")
            {
                if (val1.Length != 16)
                {
                    MessageBox.Show("状态码必须16位！！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    string msg1 = zh311(val1);
                    tbx311.Text = msg1;
                    string msg2 = zh312(val1);
                    tbx312.Text = msg2;
                    string msg3 = zh313(val1);
                    tbx313.Text = msg3;
                    string msg4 = zh314(val1);
                    tbx314.Text = msg4;
                    string msg5 = zh315(val1);
                    tbx315.Text = msg5;
                    string msg6 = zh316(val1);
                    tbx316.Text = msg6;
                    string msg7 = zh317(val1);
                    tbx317.Text = msg7;
                    string msg8 = zh318(val1);
                    tbx318.Text = msg8;
                    string msg9 = zh319(val1);
                    tbx319.Text = msg9;
                    string msg10 = zh3110(val1);
                    tbx3110.Text = msg10;
                }
            }
            else
            {
                MessageBox.Show("请输入控制器状态码！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void xtraTabPage3_Paint(object sender, PaintEventArgs e)
        {

        }

        private void toolStripStatusLabel4_Click_1(object sender, EventArgs e)
        {
         
           


        }

        private void xtraTabControl1_Click(object sender, EventArgs e)
        {

        }
    }
}
